package com.quwan.utils;

import ch.qos.logback.classic.pattern.ClassicConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.InetAddress;
import java.net.UnknownHostException;


public class LogHostProcessor extends ClassicConverter {
    private final static Logger logger = LoggerFactory.getLogger(LogHostProcessor.class);

    @Override
    public String convert(ILoggingEvent iLoggingEvent) {
        String host = null;
        try {
            host = InetAddress.getLocalHost().getHostName();
        } catch (UnknownHostException e) {
            logger.error("日志处理时获取host失败：",e);
        }
        return host;
    }
}